package com.timeDeal.servlet;










import com.timeDeal.bean.PageList;
import com.timeDeal.bean.UserBean;
import com.timeDeal.bean.XuqiufabuBean;
import com.timeDeal.service.UserService;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * Created by Administrator on 2016/7/24.
 */

public class WodeJiaoyilishiServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String  currentpage =request.getParameter("currentpage")  ;
        String flag = StringUtils.defaultString(request.getParameter("flag"),"0");
        UserBean  loginuser =   (UserBean) request.getSession().getAttribute("USER") ;
        currentpage = StringUtils.equals(currentpage,null)?"1":currentpage ;
        PageList pageList =  new PageList() ;
        int cu = Integer.valueOf(currentpage) ;
        UserService userService = new UserService();
        if(StringUtils.equals(flag,"0")) {
            pageList = userService.getJiaoyiByLishi(cu, loginuser.getYonghuid());
            request.setAttribute("pageList", pageList);
            request.setAttribute("currentpage", currentpage);
            request.getRequestDispatcher("/user/wodejiaoyilishi.jsp").forward(request, response);
        }
    else {
            pageList = userService.getJiaoyiByLishiAndShijian(cu, loginuser.getYonghuid());
            request.setAttribute("pageList", pageList);
            System.out.println(pageList.getList().size()+"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD");
            request.setAttribute("currentpage", currentpage);
            request.getRequestDispatcher("/user/shijianchushou/wodejiaoyilishi.jsp").forward(request, response);
        }




    }
}
